Skip to content

feat: pass CHARTMETRIC_REFRESH_TOKEN to sandbox environment#113

Open
sidneyswift wants to merge 2 commits intomainfrom
feature/chartmetric-sandbox-env
Open

feat: pass CHARTMETRIC_REFRESH_TOKEN to sandbox environment#113
sidneyswift wants to merge 2 commits intomainfrom
feature/chartmetric-sandbox-env

Conversation

@sidneyswift
Copy link
Copy Markdown
Contributor

@sidneyswift sidneyswift commented Mar 27, 2026

Summary

  • Adds CHARTMETRIC_REFRESH_TOKEN to getSandboxEnv() so the artist-research and chartmetric skills can access Chartmetric analytics data inside sandboxes
  • Optional — omitted when the env var is not configured, same pattern as GITHUB_TOKEN
  • 2 new tests covering include/omit behavior

Test plan

  • All 5 getSandboxEnv tests pass
  • After merging, add CHARTMETRIC_REFRESH_TOKEN to Trigger.dev project env vars

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Added album record store template with customizable video generation including movements, moods, and camera control settings
    • New caption generation guide with writing rules and curated format options for album-related content
    • Templates now support custom instructions and motion prompts for personalized content creation

Enables the artist-research and chartmetric skills to access
Chartmetric analytics data inside sandboxes. Optional — omitted
when the env var is not configured.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

Added customizable template instructions and motion prompts to the template system, introduced a new album-record-store template with comprehensive configuration files, and extended the sandbox environment to include the CHARTMETRIC_REFRESH_TOKEN. The template system now prioritizes custom instructions over generic defaults when available.

Changes

Cohort / File(s) Summary
Template System Enhancement
src/content/loadTemplate.ts, src/tasks/createContentTask.ts
Extended TemplateData interface with nullable customInstruction and customMotionPrompt fields. Updated template loading to read these fields from style guide and pass through to callers. Modified prompt instruction selection to prefer customInstruction when available, falling back to face-guide conditional defaults.
Album Record Store Template
src/content/templates/album-record-store/style-guide.json, src/content/templates/album-record-store/caption-guide.json, src/content/templates/album-record-store/video-movements.json, src/content/templates/album-record-store/video-moods.json, src/content/templates/album-record-store/references/captions/examples.json
Added complete album-record-store template configuration including style guide with camera, environment, subject, and realism parameters; caption-guide with writing rules and formats; and data files for video movements, moods, and caption examples.
Sandbox Environment Configuration
src/sandboxes/getSandboxEnv.ts, src/sandboxes/__tests__/getSandboxEnv.test.ts
Added conditional support for CHARTMETRIC_REFRESH_TOKEN environment variable. Token is included in sandbox environment when present, omitted when absent. Added corresponding test cases verifying both scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A template for records, so fine and so grand,
With custom instructions across all the land,
New tokens now flowing through sandbox so bright,
Album-store magic takes video flight! ✨🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title focuses on passing CHARTMETRIC_REFRESH_TOKEN to sandbox, but the changeset includes extensive template infrastructure (album-record-store template with style guides, captions, moods, movements) which represents a significant portion of the changes. Consider whether the title should reflect both major changes (template addition + sandbox token) or clarify if the template addition is preparatory work unrelated to the primary objective.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chartmetric-sandbox-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/content/loadTemplate.ts (1)

140-144: Note: replace() only substitutes the first occurrence of each placeholder.

If a customMotionPrompt contains multiple {movement} or {mood} placeholders, only the first of each will be replaced. This is likely fine for current use cases, but worth noting if templates evolve.

🔧 Optional: Use replaceAll for multiple placeholders
   if (template.customMotionPrompt) {
     return template.customMotionPrompt
-      .replace("{movement}", movement)
-      .replace("{mood}", mood);
+      .replaceAll("{movement}", movement)
+      .replaceAll("{mood}", mood);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content/loadTemplate.ts` around lines 140 - 144, The current custom
prompt substitution in loadTemplate.ts uses String.prototype.replace which only
replaces the first occurrence of "{movement}" and "{mood}" in
template.customMotionPrompt; update the logic in the loadTemplate function where
template.customMotionPrompt is handled to replace all occurrences (e.g., use
replaceAll("{movement}", movement) and replaceAll("{mood}", mood) or use global
regexes like .replace(/\{movement\}/g, movement) and .replace(/\{mood\}/g,
mood)) so every placeholder instance in template.customMotionPrompt is
substituted.
src/content/templates/album-record-store/style-guide.json (1)

1-36: Consider splitting unrelated changes into separate PRs.

This PR bundles two unrelated changes:

  1. Album-record-store template addition (Commit 1, this file)
  2. CHARTMETRIC_REFRESH_TOKEN sandbox environment variable (Commit 2, main PR objective)

Keeping changes focused in separate PRs improves reviewability, makes git history clearer, and simplifies rollback if needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content/templates/album-record-store/style-guide.json` around lines 1 -
36, This PR mixes two unrelated changes: the new album-record-store template
(the JSON with "name": "album-record-store" and its style-guide.json content)
and the CHARTMETRIC_REFRESH_TOKEN sandbox env var; split them by removing the
album-record-store addition from this branch/PR and creating a separate
branch/PR that contains only the new template file (style-guide.json) and its
assets, while keeping only the CHARTMETRIC_REFRESH_TOKEN environment variable
change in the current PR; ensure the new PR references the template by its
"name": "album-record-store" so reviewers can find it, and verify the current PR
contains only the env var change for CHARTMETRIC_REFRESH_TOKEN before updating
the branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/content/templates/album-record-store/style-guide.json`:
- Line 4: The usesFaceGuide flag in the template's style-guide.json is set to
true but the template contains "no person in the shot"; update the usesFaceGuide
property to false so the codepath that fetches face-guide.png (triggered by
usesFaceGuide) is skipped—locate the usesFaceGuide entry in the style-guide.json
and change its value from true to false.

---

Nitpick comments:
In `@src/content/loadTemplate.ts`:
- Around line 140-144: The current custom prompt substitution in loadTemplate.ts
uses String.prototype.replace which only replaces the first occurrence of
"{movement}" and "{mood}" in template.customMotionPrompt; update the logic in
the loadTemplate function where template.customMotionPrompt is handled to
replace all occurrences (e.g., use replaceAll("{movement}", movement) and
replaceAll("{mood}", mood) or use global regexes like .replace(/\{movement\}/g,
movement) and .replace(/\{mood\}/g, mood)) so every placeholder instance in
template.customMotionPrompt is substituted.

In `@src/content/templates/album-record-store/style-guide.json`:
- Around line 1-36: This PR mixes two unrelated changes: the new
album-record-store template (the JSON with "name": "album-record-store" and its
style-guide.json content) and the CHARTMETRIC_REFRESH_TOKEN sandbox env var;
split them by removing the album-record-store addition from this branch/PR and
creating a separate branch/PR that contains only the new template file
(style-guide.json) and its assets, while keeping only the
CHARTMETRIC_REFRESH_TOKEN environment variable change in the current PR; ensure
the new PR references the template by its "name": "album-record-store" so
reviewers can find it, and verify the current PR contains only the env var
change for CHARTMETRIC_REFRESH_TOKEN before updating the branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d5bcbad-97f6-4505-971c-425ac87c8553

📥 Commits

Reviewing files that changed from the base of the PR and between 01ba744 and 8a0c536.

📒 Files selected for processing (9)
  • src/content/loadTemplate.ts
  • src/content/templates/album-record-store/caption-guide.json
  • src/content/templates/album-record-store/references/captions/examples.json
  • src/content/templates/album-record-store/style-guide.json
  • src/content/templates/album-record-store/video-moods.json
  • src/content/templates/album-record-store/video-movements.json
  • src/sandboxes/__tests__/getSandboxEnv.test.ts
  • src/sandboxes/getSandboxEnv.ts
  • src/tasks/createContentTask.ts

{
"name": "album-record-store",
"description": "Album cover art displayed in a gritty New York record store — vinyl spinning on a turntable",
"usesFaceGuide": true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check usage of usesFaceGuide in the codebase to understand if it's referenced when customInstruction is set

# Search for usesFaceGuide references in TypeScript files
rg -n -C5 'usesFaceGuide' --type=ts

# Search for how customInstruction interacts with usesFaceGuide
rg -n -C5 'customInstruction.*usesFaceGuide|usesFaceGuide.*customInstruction' --type=ts

Repository: recoupable/tasks

Length of output: 4672


Change usesFaceGuide to false — the template has no person in the shot, so fetching a face-guide image will fail or waste resources.

Line 4 sets usesFaceGuide: true, but the template explicitly states "no person in the shot" (lines 24–26). The usesFaceGuide flag triggers a GitHub fetch for face-guide.png (regardless of customInstruction), which will fail or be unnecessary for a template without people. Set usesFaceGuide: false.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content/templates/album-record-store/style-guide.json` at line 4, The
usesFaceGuide flag in the template's style-guide.json is set to true but the
template contains "no person in the shot"; update the usesFaceGuide property to
false so the codepath that fetches face-guide.png (triggered by usesFaceGuide)
is skipped—locate the usesFaceGuide entry in the style-guide.json and change its
value from true to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant